package servlet;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import dao.DbProp;
import org.apache.log4j.PropertyConfigurator;


public class InitServlet extends HttpServlet {

	@Override
	public void init() throws ServletException {
		String sContextPath = getServletContext().getRealPath("/");
		String sFile = sContextPath + getInitParameter("db");
		System.out.println(sFile);
		try {
			FileInputStream fin = new FileInputStream(sFile);
			Properties p = new Properties();
			p.load(fin);
			DbProp.setDriver(p.getProperty("driver"));
			DbProp.setUrl(p.getProperty("url"));
			DbProp.setUser(p.getProperty("user"));
			DbProp.setPass(p.getProperty("pass"));

		} catch (FileNotFoundException e) {
			System.out.println(e.getMessage());
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}
}